package org.liveboardgames.agricola.control.commands
{
    import com.adobe.cairngorm.commands.ICommand;
    import com.adobe.cairngorm.control.CairngormEvent;
    
    import mx.collections.ListCollectionView;
    import mx.controls.Alert;
    import mx.rpc.IResponder;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    
    import org.liveboardgames.agricola.control.delegates.StartRoundDelegate;
    import org.liveboardgames.agricola.control.events.StartRoundEvent;
    import org.liveboardgames.agricola.model.AgricolaModelLocator;
    import org.liveboardgames.agricola.vo.Game;
    
    public class StartRoundCommand implements ICommand, IResponder
    {
        public function execute(event:CairngormEvent):void
        {
            var delegate:StartRoundDelegate = new StartRoundDelegate(this);
            var startRoundEvent:StartRoundEvent = StartRoundEvent(event);
            delegate.startRound(startRoundEvent.game);
        }
        
        public function result(event:Object):void
        {
//            var model:AgricolaModelLocator = AgricolaModelLocator.getInstance();
//            model.updateModel(ResultEvent(event).result as ListCollectionView);
        }
        
        public function fault(info:Object):void
        {
            var faultEvent:FaultEvent = FaultEvent(info);
            Alert.show("Could not start the new round", "Error");
        }
    
    }
}